﻿using System.Collections.Generic;
using JetBrains.Annotations;

namespace GraphShape.Controls.Extensions
{
    /// <summary>
    /// Extensions related to basic structures types.
    /// </summary>
    public static class BasicStructuresExtensions
    {
        /// <summary>
        /// Converts a <see cref="Point"/> into a <see cref="T:aPoint"/>.
        /// </summary>
        [Pure]
        public static aPoint ToPoint(this gPoint point)
        {
            return new aPoint(point.X, point.Y);
        }

        /// <summary>
        /// Converts a set of <see cref="Point"/>s into a set of <see cref="T:aPoint"/>s.
        /// </summary>
        [Pure]
        [NotNull]
        public static IEnumerable<aPoint> ToPoints([NotNull] this IEnumerable<gPoint> points)
        {
            foreach (var point in points)
            {
                yield return new aPoint(point.X, point.Y);
            }
        }

        /// <summary>
        /// Converts a <see cref="T:aPoint"/> into a <see cref="Point"/>.
        /// </summary>
        [Pure]
        public static gPoint ToGraphShapePoint(this aPoint point)
        {
            return new gPoint(point.X, point.Y);
        }

        /// <summary>
        /// Converts a set of <see cref="T:aPoint"/>s into a set of <see cref="Point"/>s.
        /// </summary>
        [Pure]
        [NotNull]
        public static IEnumerable<gPoint> ToGraphShapePoints([NotNull] this IEnumerable<aPoint> points)
        {
            foreach (var point in points)
            {
                yield return new gPoint(point.X, point.Y);
            }
        }
    }
}